package com.qujia.station.controller;


import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.common.core.page.TableDataInfo;
import com.qujia.common.utils.poi.ExcelUtil;
import com.qujia.station.domain.NonOilOrder;
import com.qujia.station.domain.PayOrder;
import com.qujia.station.domain.StationDeviceManage;
import com.qujia.station.enums.PrintEnum;
import com.qujia.station.service.NonOilOrderService;
import com.qujia.station.utils.FeiEPrinterUtil;
//import com.qujia.station.utils.YiLianYunPrinterUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * (NonOilOrder)表控制层
 *
 * @author makejava
 * @since 2023-08-16 17:46:22
 */
@RestController
@RequestMapping("/nonOilOrder")
@Api("非油品订单接口")
public class NonOilOrderController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(NonOilOrderController.class);
    /**
     * 服务对象
     */
    @Resource
    private NonOilOrderService nonOilOrderService;

    /**
     * 分页查询今日订单
     *
     * @param nonOilOrder 筛选条件
     * @return 查询结果
     */
    @PostMapping("/todayList")
    @ApiOperation("分页查询今日订单")
    public TableDataInfo queryTodayByPage(@RequestBody NonOilOrder nonOilOrder) {
        startPage();
        return getDataTable(this.nonOilOrderService.queryTodayList(nonOilOrder));
    }
    @PostMapping("/todayStatisticsData")
    @ApiOperation("查询今日订单统计")
    public AjaxResult getTodayStatisticsData(@RequestBody NonOilOrder nonOilOrder) {
        return AjaxResult.success(this.nonOilOrderService.getTodayStatisticsData(nonOilOrder));
    }

    @PostMapping("/export")
    @ApiOperation("导出")
    public AjaxResult export(@RequestBody NonOilOrder nonOilOrder){
        List<NonOilOrder> query = this.nonOilOrderService.query(nonOilOrder);
        ExcelUtil<NonOilOrder> util = new ExcelUtil<NonOilOrder>(NonOilOrder.class);
        return util.exportExcel(query, "NonOilOrder");
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/queryById/{id}")
    @ApiOperation("通过主键查询单条数据")
    public ResponseEntity<NonOilOrder> queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.nonOilOrderService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param nonOilOrder 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    @ApiOperation("新增数据")
    public AjaxResult add(@RequestBody NonOilOrder nonOilOrder) {
        return AjaxResult.success(this.nonOilOrderService.insert(nonOilOrder));
    }

    /**
     * 编辑数据
     *
     * @param nonOilOrder 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<NonOilOrder> edit(NonOilOrder nonOilOrder) {
        return ResponseEntity.ok(this.nonOilOrderService.update(nonOilOrder));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Long id) {
        return ResponseEntity.ok(this.nonOilOrderService.deleteById(id));
    }



    @GetMapping("/feiePush")
    @ApiOperation("补打票")
    public AjaxResult feiePush(PayOrder payOrder1) { //
        try {

        }catch (Exception e){
            logger.error(">pushConsumeToUser", e);
            return AjaxResult.error(e.getMessage());
        }
        return AjaxResult.success("打印成功");
    }

}

